package com.zx.kitchen.index.common.mvp.presenter;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.zx.kitchen.index.common.entity.GoodsDetailPicBean;
import com.zx.kitchen.index.common.mvp.OnResultListener;
import com.zx.kitchen.index.common.mvp.model.PurchaseGoodDetailPicModelImpl;
import com.zx.kitchen.index.common.mvp.view.GoodsDetailPicView;

/**
 * Created by Administrator on 2017/3/21.
 */

public class PurchaseGoodDetailPicModelPresenter implements OnResultListener {
    private PurchaseGoodDetailPicModelImpl purchaseGoodDetailPicModel;
    private Context mContext;
    private GoodsDetailPicView goodsDetailPicView;

    public PurchaseGoodDetailPicModelPresenter(Context mContext, GoodsDetailPicView goodsDetailPicView) {
        this.mContext = mContext;
        this.goodsDetailPicView = goodsDetailPicView;
        purchaseGoodDetailPicModel= new PurchaseGoodDetailPicModelImpl();
    }
    public void getDataFromNet(String start_time,String end_time,String type ,String goods_id){
        purchaseGoodDetailPicModel.getFromNet(1,mContext,start_time,end_time,type,goods_id,this,null);
    }

    @Override
    public void onSuccess(int requestCode, String str) {
        GoodsDetailPicBean goodsDetailPicBean = JSON.parseObject(str, new TypeReference<GoodsDetailPicBean>() {
        });
        goodsDetailPicView.onSuccess(goodsDetailPicBean);
    }

    @Override
    public void onFailure(int requestCode, String str) {
goodsDetailPicView.onFail(str);
    }
}
